package com.yuan.weike.controller;

import com.yuan.weike.common.BaseResponse;
import com.yuan.weike.common.ResultUtils;
import com.yuan.weike.service.TaskService;
import com.yuan.weike.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/stats")
public class StatsController {

    @Autowired
    private UserService userService;
    
    @Autowired
    private TaskService taskService;

    /**
     * 获取系统统计信息
     *
     * @return 统计信息
     */
    @GetMapping("/summary")
    public BaseResponse<Map<String, Object>> getSummaryStats() {
        Map<String, Object> stats = new HashMap<>();
        stats.put("userCount", userService.countUsers());
        stats.put("taskCount", taskService.countTasks());
        // 简化处理，实际项目中应该计算真实的交易总额
        stats.put("totalAmount", 0);
        return ResultUtils.success(stats);
    }
}